<?php include HEADER; ?>
<link href="<?php echo __URL_BASE ?>css/cart.css" rel="stylesheet" type="text/css">
<div class="p-cart-info">
 <table class="p-cart-order">
        <tbody>
          <tr>
            <th> Mã đơn hàng </th>
            <th style="width: 550px;"> Phương thức thanh toán </th>
            <th>Ngày đặt hàng</th>
            <th> Tổng tiền </th>
            <th> Trạng thái </th>
            
            <th style="width: 35px;"> Xóa </th>
          </tr>

  <?php 
	if(count($lstorder)>0) :
		foreach($lstorder as $item): ?>
			  
			  <tr>
				<td style="text-align:center"><a href="<?php echo __URL_BASE.'chi-tiet-don-hang/'.$item->id.'.html' ?>" title="<?php echo $item->MaHoaDon ?>" target="_blank"> 
					<?php echo $item->MaHoaDon ?>
				</a></td>
				<td>
				<?php
					$ptModel = new phuongthucthanhtoan();
					$pttt = $ptModel->getPhuongThucThanhToanById($item->idPhuongThucThanhToan);
					echo $pttt->MoTa;
				?>
				</td>
				<td style="text-align:center"><?php echo date('d/m/Y',strtotime($item->NgayDatHang)); ?></td>
				<td style="text-align:center">
				<?php
					$TongTien = 0;
					$hoadonModel = new hoadon();
					$lstChitiethd = $hoadonModel->getChiTietHoaDonByWhere('idHoaDon = ' . $item->id,'');
					foreach($lstChitiethd as $ct){
						$TongTien += $ct->Gia * $ct->SoLuong;	
					}
					$phidichvu = $TongTien*$pttt->PhiDichVu/100;
					echo '<span style="font-weight: bold;color:red;">'.number_format($TongTien + $phidichvu,0,'','.').' đ</span>';
				?>
				</td>
				<td><?php echo utility::getOrderStatus($item->TrangThai); ?></td>
				<td>
				<?php if($item->TrangThai == '0') : ?>
				<a class="delete" style="color:#3E5FE4" data-ajax="true" data-ajax-method="Get" data-ajax-mode="replace" data-ajax-update="#m-update-cart" href="<?php echo __URL_BASE.'index.php?rt=cart/update_order&hoadon_id='.$item->id ?>" onclick="return confirm('Bạn chắc chắn muốn hủy?');">(Hủy)</a>
				<?php endif; ?>
				</td>
			  </tr>
		<?php endforeach; 
		endif;
	?>
          
        </tbody>
      </table>
</div>
<?php include FOOTER; ?>